
import { debounce } from "../../utils/util";
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: String,
      value: "标题",
    },
    columns: {
      type: Array,
      value: [],
    },
    visibleItemCount: {
      type: Number,
      value: 6,
    },
    defaultIndex: {
      type: Number,
      value: 0,
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    show: false,
    showEl: false,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onShow() {
      this.setData({
        show: true,
        showEl: true,
      });
    },
    onClose() {
      const that = this;
      that.setData({
        show: false,
      });
      const debouncedHide = debounce(() => {
        that.setData({
          showEl: false,
        });
      }, 500);
      debouncedHide();
    },

    onConfirm(event) {
      const { detail } = event;
      this.triggerEvent("onConfirm", detail);
      this.onClose();
    },
  },
});
